//
//  HomeCollectionViewCell.m
//  Yarhoo
//
//  Created by 杨春至 on 2018/5/29.
//  Copyright © 2018年 Yarhoo. All rights reserved.
//

#import "HomeCollectionViewCell.h"

@interface HomeCollectionViewCell()

@property (nonatomic,strong) UIImageView *iconView;

@property (nonatomic,strong) UILabel *infoLb;

@end

@implementation HomeCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    if ([super initWithFrame:frame]) {
        [self configUI];
    }
    return self;
}
- (void)fillDataWithStr:(NSString *)str{
    _iconView.image = UIImageMake(str);
    _infoLb.text = str;
}
- (void)configUI{
    self.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.iconView];
    [self.contentView addSubview:self.infoLb];
}
- (void)layoutSubviews{
    [super layoutSubviews];
    CGFloat imgWidth = 40;
    CGFloat imgHeight = 40;
    CGFloat gap = 10;
    CGFloat textHeight = 16;
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.size.mas_equalTo(CGSizeMake(imgWidth, imgHeight));
        make.centerY.equalTo(self.contentView).offset(-gap);
    }];
    [_infoLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconView.mas_bottom).offset(gap);
        make.left.equalTo(self.contentView).offset(gap);
        make.right.equalTo(self.contentView).offset(-gap);
        make.height.equalTo(@(textHeight));
    }];
}
- (UIImageView *)iconView{
    if (!_iconView) {
        _iconView = [UIImageView new];
    }
    return _iconView;
}
- (UILabel *)infoLb{
    if (!_infoLb) {
        _infoLb = [UILabel new];
        _infoLb.textAlignment = NSTextAlignmentCenter;
        _infoLb.font = [UIFont systemFontOfSize:15];
        _infoLb.textColor = KcolorTitleBlack;
    }
    return _infoLb;
}
@end
